﻿using KinonekoSoftware.JuXiaoYouDB.Objects;

namespace KinonekoSoftware.Studio.Galleries
{
    partial class InstanceGalleryViewModel
    {
        //-------------------------------------------------------------
        //
        //          Command Handlers : Editor Mode 
        //
        //-------------------------------------------------------------
        private void DoShiftToSettingEditModeCommand()
        {
            if (Selected is null)
            {
                return;
            }

            Mode = InstanceGalleryMode.SimplifyEditMode;
        }
        
        private void DoShiftToSelectionModeCommand()
        {
            if (Selected is null)
            {
                return;
            }

            Mode = InstanceGalleryMode.SelectionMode;
        }
        
        private void DoShiftToStoryEditModeCommand()
        {
            if (Selected is null)
            {
                return;
            }

            Mode = InstanceGalleryMode.StoryEditMode;
        }
        
        private void DoShiftToInspirationEditModeCommand()
        {
            if (Selected is null)
            {
                return;
            }

            Mode = InstanceGalleryMode.InspirationEditMode;
        }
        
        private void DoShiftToGroupEditModeCommand()
        {
            if (Selected is null)
            {
                return;
            }

            Mode = InstanceGalleryMode.GroupingMode;
        }
        
        //-------------------------------------------------------------
        //
        //          Command Handlers
        //
        //-------------------------------------------------------------
        private async void DoAddGlossaryCommand()
        {
            var r = await SingleText(TitleSR.New, "新建设定");

            if (!r.IsFinished)
            {
                return;
            }

            var glossary = new Glossary
            {
                Id   = ID.Get(),
                Name = r.Value,

            };
            
            //
            // 
            _GlossaryDB.Add(glossary);
            GlossaryCollection.Add(glossary);
            
            //
            //
            Repage();
        }

        private async void DoUpdateGlossaryCommand(Glossary glossary)
        {
            
        }
        
        
        private async void DoRemoveGlossaryCommand(Glossary glossary)
        {
            
        }
        
        //-------------------------------------------------------------
        //
        //          Commands
        //
        //-------------------------------------------------------------
        public ICommandEX ShiftToSelectionModeCommand   { get; }
        public ICommandEX ShiftToSettingEditModeCommand { get; }
        public ICommandEX ShiftToGroupEditModeCommand { get; }
        public ICommandEX ShiftToStoryEditModeCommand   { get; }
        public ICommandEX ShiftToInspirationEditModeCommand { get; }
        
        
        public ICommandEX AddGlossaryCommand       { get; }
        public ICommandEX UpdateGlossaryCommand    { get; }
        public ICommandEX RemoveGlossaryCommand    { get; }

    }
}